﻿using System;
using System.Windows.Forms;
using Autofac;
using ComputerVision.Data;
using ComputerVision.Data.Repositories;
using ComputerVision.Services;
using ComputerVision.Services.RoleService;
using ComputerVision.Services.User;

namespace ComputerVision
{
    internal static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            frmSplash.ShowSplashScreen();
            Application.Run(new frmLogin());
            //Application.Run(new ANNForm());
        }

        public static readonly IContainer Container = ConfigureContainer();
        private static IContainer ConfigureContainer()
        {
            var builder = new ContainerBuilder();
            //User Service
            builder.RegisterType<UserService>().As<IService<aspnet_Users>>();
            builder.RegisterType<EntityRepository<aspnet_Users>>().As<IEntityRepository<aspnet_Users>>();
            //Roles Service
            builder.RegisterType<RoleService>().As<IService<aspnet_Roles>>();
            builder.RegisterType<EntityRepository<aspnet_Roles>>().As<IEntityRepository<aspnet_Roles>>();
            //LoaiXe
            builder.RegisterType<LoaiXeService>().As<IService<LoaiXe>>();
            builder.RegisterType<EntityRepository<LoaiXe>>().As<IEntityRepository<LoaiXe>>();
            //VeXe
            builder.RegisterType<VeXeService>().As<IService<VeXe>>();
            builder.RegisterType<EntityRepository<VeXe>>().As<IEntityRepository<VeXe>>();
            //Xe
            builder.RegisterType<XeService>().As<IService<Xe>>();
            builder.RegisterType<EntityRepository<Xe>>().As<IEntityRepository<Xe>>();
            //LoaiVe
            builder.RegisterType<LoaiVeService>().As<IService<LoaiVe>>();
            builder.RegisterType<EntityRepository<LoaiVe>>().As<IEntityRepository<LoaiVe>>();
            //ConfigrationCamera
            builder.RegisterType<ConfigrationCameraService>().As<IService<ConfigrationCamera>>();
            builder.RegisterType<EntityRepository<ConfigrationCamera>>().As<IEntityRepository<ConfigrationCamera>>();
            //Set Context
            builder.Register(c => new ComputerVisionContext()).As<IEntitiesContext>();
            return builder.Build();
        }
    }
}